using System;
using WiMo.Games.Drawables;

namespace WiMo.Games.Display.WP7S.XNA.Drawables
{
    public class Rectangle : SpriteShapeBase
    {
        public Rectangle()
        {
            FillColor = Color.Transparent;
            BorderColor = Color.Black;
            BorderWidth = 1;
            Origin = Origin.Center;
            Force = Vector2.Zero;
            ShapeType = ShapeType.Rectangle;
            CollisionShape = CollisionShapes.Rectangle;
        }

        public override WiMo.Games.Rectangle Rect 
        {
            get { return new WiMo.Games.Rectangle(Position.Point.X - (Size.Width >> 1), Position.Point.Y - (Size.Height >> 1), Size.Width, Size.Height); }
            set 
            { 
                Size = new Size(value.Width, value.Height);
                Position = new PointF(Rect.Left + Size.Width >> 1, Rect.Top + Size.Height >> 1);
            }
        }
       
        public override void Render(IDisplay display)
        {
            WiMo.Games.Rectangle drawRect;
            switch(Origin)
            {
                case Origin.Center:
                    drawRect = new WiMo.Games.Rectangle(Rect.Left - Rect.Width / 2, Rect.Top - Rect.Height / 2, Rect.Width, Rect.Height);
                    break;
                case Origin.TopLeft:
                    drawRect = Rect;
                    break;
            }

            display.Render(this);
        }

        public override void Dispose()
        {

        }
    }
}